package com.yeren.servlet.tarena.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Hello1Servlet extends HttpServlet{
	/*
	 * 使用请求中的name,contact两组参数值
	 * 分别使用getParameter和getParameterValues方法获取
	 */
	public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{
		PrintWriter out=resp.getWriter();
		//获取提交的name的值
		String name=req.getParameter("name");
		out.println("<h1>Hello,"+name+"</h1>");
		//获取提交的contacts的值
		String [] contacts=req.getParameterValues("contact");
		if(contacts!=null){
			out.print("<h1>Contact Information:</h1>");
			for(String info:contacts){
				out.print("<h1>"+info+"</h1>");
			}
		}
		out.close();
	}
}
